package com.csy.orm_mybatis.controller;


import com.csy.orm_mybatis.entity.User;
import com.csy.orm_mybatis.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author csy
 * @since 2022-04-18
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private IUserService userService;

    /**
     * 根据ID进行查询
     * @param id
     * @return
     */
    @GetMapping("/findById")
    public User findById(@RequestParam("id") Long id){
        return userService.getById(id);
    }

    @GetMapping("/query")
    public void query(){
        userService.findByPage();
    }

    @GetMapping("/findUserAndTwitter")
    public User findUserAndTwitter(@RequestParam("id") Long id){
        return userService.findUserAndTwitter(id);
    }

}

